#include<iostream>
using namespace std;


//joself prolble
//we got joself equation
//f[1]=0
//f[i]=(f[i-1]+m)%n


int main()
{
		cout<<"Please enter the size of this circle:";
		int m,n,result=0,i=0;
		cin>>n;
		cout<<"Please enter the excute number";
		cin>>m;
		for(i=2;i<=n;++i)
				result = (result+m)%n;
		cout<<"the last number is: "<<result+1<<endl;
		cin.get();
		return 0;
}
